package com.ruoyi.ftrl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ftrl.domain.HeatingManagement;
import com.ruoyi.ftrl.service.IHeatingManagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采暖季管理信息Controller
 * 
 * @author dihang
 * @date 2024-07-24
 */
@RestController
@RequestMapping("/ftrl/management")
public class HeatingManagementController extends BaseController
{
    @Autowired
    private IHeatingManagementService heatingManagementService;

    /**
     * 查询采暖季管理信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(HeatingManagement heatingManagement)
    {
        startPage();
        List<HeatingManagement> list = heatingManagementService.selectHeatingManagementList(heatingManagement);
        return getDataTable(list);
    }

    /**
     * 导出采暖季管理信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:management:export')")
    @Log(title = "采暖季管理信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HeatingManagement heatingManagement)
    {
        List<HeatingManagement> list = heatingManagementService.selectHeatingManagementList(heatingManagement);
        ExcelUtil<HeatingManagement> util = new ExcelUtil<HeatingManagement>(HeatingManagement.class);
        util.exportExcel(response, list, "采暖季管理信息数据");
    }

    /**
     * 获取采暖季管理信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:management:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(heatingManagementService.selectHeatingManagementById(id));
    }

    /**
     * 新增采暖季管理信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:management:add')")
    @Log(title = "采暖季管理信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HeatingManagement heatingManagement)
    {
        return toAjax(heatingManagementService.insertHeatingManagement(heatingManagement));
    }

    /**
     * 修改采暖季管理信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:management:edit')")
    @Log(title = "采暖季管理信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HeatingManagement heatingManagement)
    {
        return toAjax(heatingManagementService.updateHeatingManagement(heatingManagement));
    }

    /**
     * 删除采暖季管理信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:management:remove')")
    @Log(title = "采暖季管理信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(heatingManagementService.deleteHeatingManagementByIds(ids));
    }
}
